-
Notifications
You must be signed in to change notification settings - Fork 13
Remove need of project.afterEvaluate() and add generateJavadoc macro task #57
Conversation
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
==========================================
+ Coverage 9.09% 22.09% +13%
- Complexity 3 8 +5
==========================================
Files 2 2
Lines 66 86 +20
Branches 7 9 +2
==========================================
+ Hits 6 19 +13
- Misses 60 63 +3
- Partials 0 4 +4
Continue to review full report at Codecov.
|
README.md
Outdated
@@ -2,7 +2,7 @@ | |||
|
|||
Gradle plugin that generates Java Documentation from an Android Gradle project. | |||
|
|||
Works with the latest Gradle Android Tools version 3.0.1. | |||
Works with the latest Gradle Android Tools version 3.1.2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert? I'll update the README once I've published a new version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
README.md
Outdated
@@ -31,20 +31,34 @@ buildscript { | |||
maven { url "https://oss.sonatype.org/content/repositories/snapshots" } | |||
} | |||
dependencies { | |||
classpath "com.vanniktech:gradle-android-javadoc-plugin:0.3.0-SNAPSHOT" | |||
classpath "com.vanniktech:gradle-android-javadoc-plugin:0.3.1-SNAPSHOT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
README.md
Outdated
} | ||
} | ||
|
||
apply plugin: "com.vanniktech.android.javadoc" | ||
``` | ||
|
||
or with plugins dsl from version `0.3.1-SNAPSHOT` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this either as it's in the gradle link
gradle.properties
Outdated
@@ -1,5 +1,5 @@ | |||
GROUP=com.vanniktech | |||
VERSION_NAME=0.3.0-SNAPSHOT | |||
VERSION_NAME=0.3.1-SNAPSHOT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to change
applyPluginToProject(p); | ||
} else { | ||
logger.info "${p.name} is not an android project - plugin is not applied" | ||
// Do not apply in root project anymore. User will have to apply plugin manually in all child project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually a fan of having it on the root project and then apply everywhere else.
Why do you want to change it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, you convince me. I've put again the project.allProject{}
addJavaTaskToProjectWith(project, (DomainObjectCollection<BaseVariant>) project.android.libraryVariants) | ||
} else { | ||
// Do not throw exception anymore to support big projects with a lot of modules that not all of them are android. | ||
logger.info "${project.name} has no application or library variant - plugin is not applied" | ||
} | ||
} | ||
|
||
private void createRootTask(Project project) { | ||
if (project.tasks.findByPath(JAVADOC_TASK)) { | ||
logger.debug "task $JAVADOC_TASK already exists" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how can this happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can happen if user create a task with the same name or if he applies a plugin that create a task with the same name.
It is still very unlikely...
} | ||
} | ||
if (project.tasks.findByPath(JAVADOC_JAR_TASK)) { | ||
logger.debug "task $JAVADOC_JAR_TASK already exists" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
group = 'Documentation' | ||
|
||
destinationDir = getJavadocFolder(project, variant) | ||
source = variant.javaCompiler.source | ||
|
||
ext.androidJar = "${project.android.sdkDirectory}/platforms/${project.android.compileSdkVersion}/android.jar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happened to the android.jar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been replaced by project.android.getBootClasspath()
It is used in the doFirst{} closure just bellow.
829d83a
to
ae7bda3
Compare
|
||
compileOnly 'com.android.tools.build:gradle:3.1.2' | ||
|
||
testCompile 'com.android.tools.build:gradle:3.1.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this when using compileOnly
? I'm not sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we need this, Unit tests are pretty much clear ^^
Unit tests do need the android dependency at runtime also
applyPluginToProject(p); | ||
} else { | ||
logger.info "${p.name} is not an android project - plugin is not applied" | ||
if (isRoot(project)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change it to this? I'm also using the same code in other gradle projects and would like to be consistent:
def hasSubProjects = project.subprojects.size() > 0
if (hasSubProjects) {
project.subprojects { subProject ->
applyPlugin(subProject)
}
} else {
applyPlugin(project)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
|
||
private void applyPlugin(Project project) { | ||
if (project.hasProperty('android')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this at all when using the whenPluginAdded
method. Less code and clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we need this, because whenPluginAdded
is not called if plugin has been applied before this one
} else { | ||
// Waiting for android plugin to be applied | ||
project.plugins.whenPluginAdded { Plugin plugin -> | ||
if (project.plugins.hasPlugin("com.android.library") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also support the other android plugins? If so you can use:
private static boolean isAndroidProject(final Project project) {
final boolean isAndroidLibrary = project.plugins.hasPlugin('com.android.library')
final boolean isAndroidApp = project.plugins.hasPlugin('com.android.application')
final boolean isAndroidTest = project.plugins.hasPlugin('com.android.test')
final boolean isAndroidFeature = project.plugins.hasPlugin('com.android.feature')
final boolean isAndroidInstantApp = project.plugins.hasPlugin('com.android.instantapp')
return isAndroidLibrary || isAndroidApp || isAndroidTest || isAndroidFeature || isAndroidInstantApp
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have replaced this by plugin instanceOf com.android.build.gradle.BasePlugin
It cover all other android plugins.
Also, there was an issue because plugin was applied each time a new plugin was applied after android ones. Now Javadoc plugin is applied only once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better. Some final notes and then we can merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Hi,
I have made some changes to javadoc plugin. Could please review these changes and make some comments about it ?
build.gradle
I am now using plugins dsl to ease read.
I also changed the dependency to android gradle plugin with
compileOnly
configuration. This prevents this lib to be added to dependencies in pom.xmlGeneration.groovy
I choose to not add the plugin to child projects in case it is added to a root project of multi module build. Please advise me if it is a bad idea.
I also removed the
afterEvaluate
closure in favor ofvariant.all
ones.I am also creating root task named
generateJavadoc
. Running this task will run javadoc task for all variants. The same for the Jar.Last but not least : this plugin can be added before android plugin is applied.
Thanks